home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / 80X86 / ASMFAQ.ZIP / ASM_FAQ2.TXT < prev    next >
Encoding:
Internet Message Format  |  1996-04-03  |  28.2 KB

  1. From news.primenet.com!nntp.news.primenet.com!news.sprintlink.net!gryphon.phoenix.net!academ!binky.capnet.state.tx.us!goblin.tdh.state.tx.us!geraldo.cc.utexas.edu!cs.utexas.edu!math.ohio-state.edu!howland.reston.ans.net!swrinde!sgigate.sgi.com!news1.best.com!news.aimnet.com!ns2.mainstreet.net!sloth.swcp.com!news.dgsys.com!DGS.dgsys.com!raymoon Tue Apr  2 15:45:00 1996
  2. Path: news.primenet.com!nntp.news.primenet.com!news.sprintlink.net!gryphon.phoenix.net!academ!binky.capnet.state.tx.us!goblin.tdh.state.tx.us!geraldo.cc.utexas.edu!cs.utexas.edu!math.ohio-state.edu!howland.reston.ans.net!swrinde!sgigate.sgi.com!news1.best.com!news.aimnet.com!ns2.mainstreet.net!sloth.swcp.com!news.dgsys.com!DGS.dgsys.com!raymoon
  3. From: raymoon@dgsys.com (Raymond Moon)
  4. Newsgroups: alt.lang.asm,comp.lang.asm.x86,news.answers,alt.answers,comp.answers
  5. Subject: x86 Assembly Language FAQ - General Part 2/3
  6. Supersedes: <4gdskr$o9c@news.dgsys.com>
  7. Followup-To: alt.lang.asm,comp.lang.asm.x86
  8. Date: 21 Mar 1996 22:50:08 GMT
  9. Organization: MoonWare
  10. Lines: 656
  11. Approved: news-answers-request@MIT.EDU
  12. Distribution: world
  13. Expires: Sat, 20 Apr 1996 23:59:59 GMT
  14. Message-ID: <4ismf0$2tq@news.dgsys.com>
  15. Reply-To: raymoon@moonware.dgsys.com
  16. NNTP-Posting-Host: dgs.dgsys.com
  17. Summary: This is the FAQ for the x86 Assembly Language programmers for the
  18.  alt.lang.asm and comp.lang.asm.x86 newsgroups.  This particular section of
  19.  the FAQ is part two of three parts that contain x86 assembly language
  20.  information common to all assemblers.
  21. Keywords: x86 Assemby Language ASM FAQ General
  22. X-Newsreader: TIN [version 1.2 PL2]
  23. Xref: news.primenet.com alt.lang.asm:8421 comp.lang.asm.x86:18598 news.answers:66831 alt.answers:16273 comp.answers:17530
  24.  
  25. Archive-name: assembly-language/x86/general/part2
  26. Posting-Frequency: monthly (21st of every month)
  27. Last-modified: 1996/03/19
  28.  
  29. ------------------------------
  30.  
  31. Subject: 15. How To Determine If A Pentium With The FDIV Problem Is Present
  32.  
  33. The following is a short assembly language program that can detect the FDIV
  34. error: (It has been pointed out to me that the test against zero may lead
  35. to a false positive.  On my 387, the result is exactly zero so that is why
  36. I coded it that way.  PENERR has been tested on and identifies a Pentium
  37. with the FDIV error.)
  38.  
  39. =================================================================
  40. ;   PENERR.ASM - Determines if Pentium FDIV error is present
  41. ;   Version 1.00
  42. ;   Copyright 1994 - Raymond Moon
  43. ;   This program is free for all to use.
  44.     .286
  45.     .287
  46. DGROUP  GROUP   _TEXT, _DATA
  47. _DATA   SEGMENT PARA PUBLIC 'DATA'  ; Data segment
  48. x   dd      4195835
  49. y   dd      3145727
  50. OK  byte    'No Error$'
  51. ERR byte    'Pentium Error Present', 7, '$'
  52. _DATA   ENDS
  53.  
  54. _TEXT   SEGMENT WORD PUBLIC 'CODE'  ; Code segment
  55.     assume cs:DGROUP, ds:DGROUP
  56.         org 100h
  57. START:  finit
  58.         fld x
  59.         fld st
  60.         fld y               ; 0 = y; 1 & 2 = x
  61.         fdiv    st(2), st   ; 0 = y; 1 = x; 2 = x/y
  62.         fmulp   st(2), st   ; 0 = x, 1 = (x/y)*y
  63.         fsubp   st(1), st   ; 0 = (x/y)*y-x => should be zero
  64.         fldz                ; 0 = 0; 1 = (x/y)*y-x
  65.         fcomp   st(1)       ; Is it zero
  66.         fstsw   ax          ; get control word
  67.         ffree   st(1)
  68.         ffree   st
  69.         sahf                ; load flag register
  70.         jz      EQUAL       ; If C3 not set, result = 0
  71.         lea dx, ERR         ; DS:DX => ERR
  72.          jmp OUTPUT
  73. EQUAL:  lea dx, OK          ; DS:DX => OK
  74. OUTPUT: mov ah, 9h          ; Display string
  75.         int 21h
  76.         int 20h             ; Terminate program
  77. _TEXT   ends
  78.         end START
  79. =================================================================
  80. penerr.com in uuencode for those who do not want to assemble the above
  81. source code.
  82. =================================================================
  83. begin 644 penerr.com
  84. MF]OCV09``=G`V09$`=SZWLK>Z=GNV-F;W^#=P=W`GG0&C191`>L$C19(`;0)
  85. MS2'-(````````````````````/L%0`#__R\`3F\@17)R;W(D4&5N=&EU;2!%
  86. .<G)O<B!0<F5S96YT!R1R
  87. `
  88. end
  89.  
  90. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  91. Last changed: 5 Jan 95
  92.  
  93. ------------------------------
  94.  
  95. Subject: 16. Accessing 4 Gigs of Memory in Real Mode
  96.  
  97. Flat real mode is a popular name for a technique used to access up to 4 GB
  98. of memory, while remaining in real mode.  This technique requires a 80386
  99. or higher processor.  The address space really is not flat, actually, this
  100. technique allows you treat one or more segments as large (32-bit) segments,
  101. thereby accessing memory above 1 MB.
  102.  
  103. When the CPU accesses memory, the base address of the segment used is not
  104. described by the value currently in the appropriate register.  The value is
  105. stored internally in a structure known as the descriptor cache.  Changing
  106. the value of a segment register results in that segment's entry in the
  107. descriptor cache being recalculated according to the rules of the current
  108. mode.  In real mode, the value of the segment register is shifted left four
  109. bits to find the base address of the segment, and the size of the segment
  110. is always 64k.  In protected mode, the value in the segment register is
  111. used as an index into a descriptor table located in memory, and the base
  112. address and size (which may be as small as 4 KB, or as large as 4 GB)from
  113. the descriptor table are loaded into the descriptor cache.
  114.  
  115. When the processor changes modes, the contents of the processor's internal
  116. descriptor cache are not changed.  The reason is because changing them
  117. would result in (at the very least) the code segment being recalculated
  118. according to the new mode's rules, most likely causing your program to
  119. crash.  Thus the program must load the segment registers with sensible
  120. values after the mode switch occurs.  Consider an example where real mode
  121. code is located in segment 1000h.  If switching modes caused an immediate
  122. recalculation of the descriptor cache, the processor would attempt to read
  123. entry 1000h of the descriptor table immediately upon switching to protected
  124. mode.  Even if this were a valid descriptor (unlikely), it would have to
  125. have a base address identical to real mode segment 1000h (i.e., 10000h),
  126. and a size limit of 64 KB to prevent a probable crash.  An invalid
  127. descriptor would cause an immediate processor exception.
  128.  
  129. Normally, aside from preventing situations like that in the above example,
  130. there is little to be said about this feature.  After all, as soon as you
  131. reload new values into the segment register, the descriptor cache entry for
  132. that segment will be reset according to the rules of the current mode. 
  133. After switching from protected mode to real mode, however, when you load
  134. the segment registers with their new values, the segment's base address is
  135. recalculated according to real mode rules, but the size limit is not
  136. changed.  After setting the 4 GB limit (which must be done in protected
  137. mode), it will stay in place until changed by another protected mode
  138. program, regardless of what values are loaded in the segment register in
  139. real mode.
  140.  
  141. So, the steps to using this technique are as follows:
  142.     1.  Set up a bare bones global descriptor table, with a null entry, and
  143. a single entry for a 4 GB segment.  The base address of this segment is not
  144. important.
  145.     2.  If you don't wish to define an interrupt descriptor table (IDT),
  146. you must disable interrupts before switching to protected mode.  You do not
  147. need a full-fledged protected mode environment for this, so it is easiest
  148. just to disable interrupts and not worry about the IDT.
  149.     3.  Switch to protected mode. 
  150.     4.  Load the segment registers you wish to change with the selector for
  151. the 4 GB segment.  I recommend using FS and/or GS for this purpose, for
  152. reasons I'll describe below.
  153.     5.  Return to real mode.
  154.     6.  Re-enable interrupts.
  155.  
  156. After these steps, you can then load your segment registers with any value
  157. you wish.  Keep in mind that the base address will be calculated according
  158. to real mode rules.  Loading a value of 0 into a segment register will
  159. result in a 4 GB segment beginning at physical address 0.  You can use any
  160. of the usual 32-bit registers to generate offsets into this segment.
  161.  
  162. Some points to keep in mind:
  163.     1.  Some software depends on 64 KB segment wrap-around.  While rare, it
  164. is possible that you will encounter software that crashes if the older
  165. segments (DS or ES) are 4 GB in size.  For that reason, I recommend only
  166. using FS and/or GS for this purpose, as they are not used as widely as the
  167. others.
  168.     2.  You should never change the limit of the code segment.  The
  169. processor uses IP (not EIP) to generate offsets into the code segment in
  170. real mode; any code beyond the 64 KB mark would be inaccessible, regardless
  171. of the segment size.
  172.     3.  You should never change the limit of the stack segment.  This is
  173. similar to the above; the processor uses SP in real mode, rather than esp.
  174.     4.  Because of the necessity of switching to protected mode, this
  175. technique will not work in a virtual 8086 mode "DOS box" from Windows,
  176. OS/2, or any other protected mode environment.  It only works when you
  177. start from plain, real mode DOS.  Many memory managers also run DOS in V86
  178. mode, and prevent the switch to protected mode.  It is possible to use VCPI
  179. to work around this, but if you go to that length you will probably find
  180. that you have implemented a complete protected mode environment, and would
  181. not need to return to real mode anyway.
  182.     5.  This technique will not work in the presence of any protected mode
  183. software that changes segment size limits.  When that software returns
  184. control to your real mode program, the limits will be the values to which
  185. the protected mode code set them.  If these limits are different that what
  186. your program used, problems can result.  At the very least, your program
  187. will return incorrect results when accessing data stored in extended
  188. memory.  At worst, your program will crash and burn.
  189.  
  190. The benefits of this technique are many.  Most importantly, you can access
  191. extended memory without resorting to slow BIOS calls or having to implement
  192. a complete DOS extender.  If your program uses interrupts extensively
  193. (timer interrupts for animation or sound, for example), real mode is a
  194. better choice because protected mode handles interrupts slower.  DOS itself
  195. uses this technique in HIMEM.SYS as a fast, practical method of providing
  196. access to extended memory.
  197.  
  198. Code demonstrating this technique is available in the file, realmem.zip. 
  199. This file is available using anonymous ftp from x2ftp.oulu.fi in the
  200. directory, pub/msdos/programming/memory.
  201.  
  202. For further reading on this topic, I suggest "DOS Internals," by Geoff
  203. Chappell.  It is published by Addison-Wesley as part of the Andrew Schulman
  204. Programming Series.  The ISBN number is 0-201-60835-9.
  205.  
  206. Contributor: Sherm Pendley, grinch@access.mountain.net
  207. Last changed: 15 Jan 95
  208.  
  209. ------------------------------
  210.  
  211. Subject: 17. What Is Available at ftp.intel.com
  212.  
  213. To obtain a description of the files available at Intel:
  214.  
  215.     ftp://ftp.intel.com/pub/IAL
  216.     get libdir.txt
  217.  
  218. Most of the files are press releases, but there are some hidden jewels. 
  219. Search for and read the files under the Intel386, Intel486 and Pentium
  220. subdirectories.  Here are a sample of files that may be of interest (path
  221. from IAL subdirectory is given):
  222.  
  223. Pentium/opt32.doc - Optimizations for Intel's 32-bit processors in MS Word
  224.     format.
  225. Pentium/pairng.txt - Instruction pairing optimization for Pentium processor
  226.     - text format.
  227. Pentium/p5cpui.txt - new official CPU identification scheme - text format.
  228. Pentium/p5masm.mac - MASM macros for instructions new with Pentium
  229. Tools_Utils_Demos/prot.txt - MASM code for entering protected mode - text
  230.     format.
  231. Intel486/2asm10.zip - C source for 8086-80486 16/32 bit disassembler -
  232.     pkzip format.
  233.  
  234. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  235. Last changed: 8 Jan 95
  236.  
  237. ------------------------------
  238.  
  239. Subject: 18. Interrupts and Exceptions
  240.  
  241.     "(with interrupts) the processor doesn't waste its time looking for
  242.     work - when there is something to be done, the work comes looking for
  243.     the processor."
  244.                                     - Peter Norton
  245.  
  246. INTERRUPTS AND EXCEPTIONS
  247.  
  248. Interrupts and exceptions both alter the program flow. The difference
  249. between the two is that interrupts are used to handle external events
  250. (serial ports, keyboard ) and exceptions are used to handle instruction
  251. faults, (division by zero, undefined opcode).
  252.  
  253. Interrupts are handled by the processor after finishing the current
  254. instruction. If it finds a signal on its interrupt pin, it will look up the
  255. address of the interrupt handler in the interrupt table and pass that
  256. routine control.  After returning from the interrupt handler routine it
  257. will resume program execution at the instruction after the interrupted
  258. instruction.
  259.  
  260. Exceptions on the other hand are divided into three kinds.  These are
  261. Faults, Traps and Aborts.  Faults are detected and serviced by the
  262. processor before the faulting instructions.  Traps are serviced after the
  263. instruction causing the trap. User defined interrupts goes into this
  264. category and can be said to be traps, this includes the MS-DOS INT 21h
  265. software interrupt for example.  Aborts are used only to signal severe
  266. system problems, when operation is no longer possible.
  267.  
  268. See the below table for information on interrupt assignments in the Intel
  269. 386, 486 SX/DX processors, and the Pentium processor. Type specifies the
  270. type of exception.
  271.  
  272. ---------------------------------------------------------------------
  273. Vector number   Description
  274. ---------------------------------------------------------------------
  275.      0          Divide Error (Division by zero)
  276.      1          Debug Interrupt (Single step)
  277.      2          NMI Interrupt
  278.      3          Breakpoint
  279.      4          Interrupt on overflow
  280.      5          BOUND range exceeded
  281.      6          Invalid Opcode
  282.      7          Device not available (1)
  283.      8          Double fault
  284.      9          Not used in DX models and Pentium (2)
  285.     10          Invalid TSS
  286.     11          Segment not present
  287.     12          Stack exception
  288.     13          General protection fault
  289.     14          Page fault
  290.     15          Reserved
  291.     16          Floating point exception (3)
  292.     17          Alignment check (4)
  293.     18 - 31     Reserved on 3/486, See (5) for Pentium
  294.     32 - 255    Maskable, user defined interrupts
  295. ---------------------------------------------------------------------
  296. (1) Exception 7 is used to signal that a floating point processor is not
  297.     present in the SX model. Exception 7 is used for programs and OSes that
  298.     have floating point emulation. Also the DX chips can be set to trap
  299.     floating point instructions by setting bit 2 of CR0.
  300. (2) Exception 9 is Reserved in the DX models and the Pentium, and is only
  301.     used in the 3/486 SX models to signal Coprocessor segment overrun. This
  302.     will cause an Abort type exception on the SX.
  303. (3) In the SX models this exception is called 'Coprocessor error'.
  304. (4) Alignment check is only defined in 486 and Pentiums. Reserved on any
  305.     other Intel processor.
  306. (5) For Pentiums Exception 18 is used to signal what is called an 'Machine
  307.     check exception'.
  308.  
  309. The other interrupts, (32-255) are user defined. They differ in use from
  310. one OS to another.
  311.  
  312. For a list of MS-DOS interrupts, see 'Obtaining HELPPC' (Subject #6) or
  313. Ralf Browns Interrupt List (Subject #11)
  314.  
  315. Contributor: Patrik Ohman, patrik@astrakan.hgs.se
  316. Last changed: 10 Jan 95
  317.  
  318. ------------------------------
  319.  
  320. Subject: 19. ASM Books Available
  321.  
  322. The format is Author, Title, Level, and short description
  323.  
  324. Ray Duncan
  325. Advanced MSDOS Programming
  326. Advanced
  327. Both a tutorial and a reference for MS-DOS capabilities and services,
  328. including reference sections on DOS function calls, IBM ROM BIOS, mouse
  329. driver and LAM. expanded memory. Excellent quality example programs
  330. throughout.
  331.  
  332. By Peter Norton and John Socha
  333. Peter Norton's Assembly Language Book For the IBM PC
  334. Novice
  335. Good for an introduction to Assembly Language.  Plenty of programming
  336. examples.  Older versions of this book used to have a sample disk.  And as
  337. you read the book, you slowly add on code to what eventually is Disk Patch
  338. - the book's version of Norton's commercially  Disk Edit.  Great for
  339. complete beginners seeking novice rank.
  340.  
  341. ***** WARNING -- Next two books may come with virus infected disk.  Use
  342. your anti-virus software to check and clean, if necessary, these diskettes!
  343.  
  344. Maljugin, Izrailevich, Sopin, and Lavin
  345. The Revolutionary Guide to Assembly Language
  346. Novice
  347. This is one of the best introductory texts I've ever seen  There are so
  348. many authors since the topic is broken down into specific categories:
  349. video, BIOS, keyboard, etc..  Most intro texts force you to follow a set
  350. plan of learning assembly, but in this book you can turn to a specific
  351. topic almost immediately.  It's so-so as a reference book, however - a few
  352. tables of interrupts in the back. 
  353.  
  354. Maljugin, Izrailevich, Sopin, and Lavin
  355. Master Class Assembly Language
  356. Advanced
  357. Review: This is the sequel to The Revolutionary Guide To Assembly Language. 
  358. Equally thick and massive, it covers many of the topics we see today -
  359. hardware interfaces, sound cards, data compression, even protected mode
  360. programming.  Brief review of assembly at the beginning, but moves very
  361. quickly.  Read this if you're intermediate seeking expert status. 
  362. Definitely not recommended for beginners.  If you are a beginner and you
  363. think you like the topics covered in this book, buy the one before it too. 
  364. Also comes with a disk of source code examples from the book (MASM highly
  365. recommended, not TASM).
  366.  
  367. ***** End of Possible Virus Alert
  368.  
  369. Alan Wyatt
  370. Advanced Assembly Language
  371. Advanced
  372. This book's best feature is it comprehensive guide on device drivers. 
  373. There are good chapters on controlling the mouse, file access, using
  374. memory, etc.
  375.  
  376. Ralf Brown and Jim Kyle
  377. PC Interrupts - 2nd Edition
  378. Intermediate/Advanced
  379. The definitive book on interrupt programming for PC's and compatibles. 
  380. Based on the freeware Interrupt List by Ralf Brown
  381.  
  382. For an extensive book list without descriptions, point your web browser to
  383.     http://alaska.net/~rrose/assembly.htm
  384. Sites with more books but no reviews are:
  385.         http://www.fys.ruu.nl/~faber/Amain.html
  386.         http://www.poweramp.net/~jvahn
  387.  
  388. Contributors:  Antonio Alonso, Solomon Chang, Paul Gilbert, Dave Navarro,
  389. Mike Schmit and James Vahn.
  390. Last changed: 19 Dec 95
  391.  
  392. ------------------------------
  393.  
  394. Subject: 20. ASM Code Available On The Internet
  395.  
  396. 20.1    SIMTEL SITES
  397.  
  398. The SimTel has a directory devoted to assembly language. 
  399.  
  400.     ftp://ftp.coast.net/SimTel/msdos/asmutil
  401. or
  402.     http://simtel.coast.net/SimTel/
  403.  
  404. 20.2    80xxx Snippets
  405.  
  406. Fidonet's echo for 80xxx programming has a collection of code that is
  407. maintained by Jim Vahn, jvahn@short.circuit.com.  The collection is
  408. available via mail based archive server or Fidonet file requests to
  409. 1:346/15.
  410.  
  411. To get a list of files available via e-mail, send an empty message to
  412. files@circuit.com.  The server will return a list of all files available
  413. and instruction on how to retrieve them.
  414.  
  415. The assembly language snippets dated before Mar 93 are available in one zip
  416. file at the above SimTel sites under the filename 80XXX393.ZIP.
  417.  
  418. The Snippets are now on the web.  In addition to downloading the snippets
  419. there is an assembly language related book list.  The URL is:
  420.  
  421.     http://www.poweramp.net/~jvahn/
  422.  
  423. 20.3    X2FTP.OULU.FI
  424.  
  425. This ftp site, x2ftp.oulu.fi, has some asm source code not available at the
  426. SIMTEL sites.  The following describes some directories and the type of
  427. information that is available in them.
  428.  
  429. /pub/msdos/programming/pmode - protected mode utilities and some source
  430.     code.
  431. /pub/msdos/programming/source - some asm code
  432. /pub/msdos/programming/prgsrc - some asm code
  433.  
  434. 20.4  FTP.X86.ORG
  435.  
  436. This ftp site contains much of the code and information available from
  437. Robert Collins' web site.
  438.  
  439.     ftp://ftp.x86.org/x86
  440.  
  441. 20.5 OMEN.COM
  442.  
  443. Omen has assembly language source available from its web site.  The address
  444. is:
  445.     http://www.omen.com.au/Files/asm.html
  446.  
  447. Much of the code is archived in the .arj format.  You will need the
  448. appropriate.  One is available:
  449.  
  450.     ftp://ftp.coast.net/SimTel/msdos/archiver/arj242b.exe
  451.  
  452. 20.6 JUMBO
  453.  
  454. JUMBO is the Official Web Shareware Site.  It has a directory devoted to
  455. assembly language source code, libraries and utilities:
  456.  
  457.     http://www.jumbo.com/prog/dos/asmutil
  458.  
  459. 20.7 THE REEF
  460.  
  461. This FTP site has source code and information that I have not found else
  462. where.  Unfortunately, many of the files are compressed using arj and lzh.
  463.  
  464.     ftp://futute.dreamscape.com/pub/thereef/asm
  465.  
  466. 20.8 PC GAMES PROGRAMMER ENCYCLOPEDIA
  467.  
  468. This encyclopedia is a collection of files related to game programming. 
  469. Many of these files contain programming examples.  Topics included are ASM
  470. tutorial, VGA and SVGA programming information, graphic algorithms, graphic
  471. file formats, soundcard and other PC hardware programming information. 
  472. This file is available from:
  473.     ftp://teeri.oulu.fi/pub/msdos/programming/gpe/pcgpe10.zip
  474.  
  475. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  476. Last changed: 8 Jan 96
  477.  
  478. ------------------------------
  479.  
  480. Subject: 21. How To Commit A File
  481.  
  482. The easiest solution is to open or create the file to be committed using
  483. Int 21h function 6ch, extended open/create.  The BX register contains the
  484. desired Open Mode.  One option that can be or'ed into this register is what
  485. Microsoft calls, OPEN_FLAGS_COMMIT, that has the value of 4000h.  Using
  486. this option caused DOS to commit the file after each write.  This function
  487. has been available (documented) since DOS 4.0.
  488.  
  489. If you do not want to commit the file at each write but only when certain
  490. conditions are met, use Int 21h function 68h, commit file.  The functions
  491. has been available (documented) since DOS 3.3.
  492.  
  493. If you need to support versions of DOS before 3.3, the following technique
  494. will flush the all stored data without closing and opening the file.  It is
  495. the opening of the file that is time consuming.
  496.     1.  Use 21h function 45h to create a duplicate file handle to the file
  497.         to be flushed.
  498.     2.  Close that duplicate file handle.
  499.  
  500. This technique will work all the way back to DOS 2.0.
  501.  
  502. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  503. Last changed: 30 Jan 95
  504.  
  505. ------------------------------
  506.  
  507. Subject: 22. Using Extended Memory Manager
  508.  
  509. 22.1  HOW TO USE XMS
  510.  
  511. XMS usage - short recipe:
  512. 1.  Verify have at least 286 (pushf; pop AX; test AX,AX; js error).
  513. 2.  Verify vector 2Fh set (DOS 3+ sets it during boot).
  514. 3.  AX=4300h, int 2Fh, verify AL=80h (means XMS installed).
  515. 4.  AX=4310h, int 2Fh, save ES:BX as dword XmsDriverAddr.
  516. 5.  AH=8, call [XmsDriverAddr] - returns ax=largest free XMS memory block
  517.     size in kB (0 if error).
  518. 6.  AH=9, DX=required size in kB, call [XmsDriverAddr] - allocates memory
  519.     (returns handle in DX - save it).
  520. 7.  AH=0Bh, DS:SI->structure {
  521.         dword size (in bytes and must be even),
  522.         word source_handle,
  523.         dword source_offset,
  524.         word destination_handle,
  525.         dword destination_offset }
  526.     (if any handle is 0, the "offset" is Real Mode segment:offset)
  527. 8.  AH=0Fh, BX=new size in kB, DX=handle, call [XmsDriverAddr] - changes
  528.     memory block size (without losing previous data).
  529. 9.  AH=0Ah, DX=handle, call [XmsDriverAddr] - free handle and memory.
  530.  
  531. Initially, should process #1-#6, then can use #7 to put data in/get
  532. data from XMS memory, or #8 to change XMS memory block size.  On exit
  533. use #9 to free allocated memory and handle.
  534.  
  535. Hint: handle cannot be 0, since zero is used as "no handle allocated"
  536. value.
  537.  
  538. Errors for XMS calls (except AH=7 - Query A20) are signaled by AX=0. Error
  539. code returned in BL, few codes can check for are:
  540.     80h - not implemented,
  541.     81h - VDISK detected (and it leaves no memory for XMS),
  542.     82h - A20 error (e.g. fail to enable address line A20),
  543.     A0h - all allocated,
  544.     A1h - all handles used,
  545.     A2h - invalid handle,
  546.     A3h/A4h - bad source handle/offset,
  547.     A5h/A6h - bad destination handle/offset,
  548.     A7h - bad length,
  549.     A8h - overlap (of source and destination areas on copy),
  550.     A9h - parity error (hardware error in memory),
  551.     ABh - block is locked,
  552.     00h - OK
  553.  
  554. For more info read INT 2Fh, AH=43h in Ralf Brown interrupt list.
  555.  
  556. 22.2  WHAT IS THE 'LINEAR BLOCK ADDRESS' RETURNED BY LOCK MEM BLOCK?
  557.  
  558. When you lock mem block, XMS driver arranges memory governed by it in a way
  559. the locked block forms one contiguous area in linear address space and
  560. returns you starting address of the memory.  Linear address is base address
  561. of segment + offset in segment, in Real Mode it is segment*16+offset, in
  562. Protected Mode the base address is kept in LDT or GDT; note offset can be
  563. 32-bit on 386+.  If paging isn't enabled, linear address = physical
  564. address.  You don't need the linear address unless you use 32-bit offsets
  565. in Real Mode or you use Protected Mode (see previous answer for explanation
  566. how you can access XMS memory).
  567.  
  568. Contributor: Jerzy Tarasiuk, JT@zfja-gate.fuw.edu.pl
  569. Last Changed: 30 Jan 95
  570.  
  571. ------------------------------
  572.  
  573. Subject: 24. EXE2BIN Replacement
  574.  
  575. A utility, EXE2BIN, used to be included in DOS.  This utility was needed to
  576. convert the output of the linker from .EXE to .com format because the
  577. linkers could not do this directly.  As linkers became more capable, the
  578. need for this utility vanished, so EXE2BIN was dropped from DOS.  If you
  579. still are using an older assembler and linker, you now have been left out
  580. in the cold.  Well, not quite, as there are three shareware equivalent
  581. programs.
  582.  
  583. 23.1 EXECOM14.ZIP
  584.  
  585. EXECOM was written by Chris Dunford in C.  The .zip file contains the
  586. executable, documentation and the .c source that Chris Dunford has released
  587. into the public domain.  The current version is 1.04 with a 2 Mar 88 date.
  588.  
  589. 23.2 BIN.ZIP
  590.  
  591. This replacement version was written by Bob Tevithick.  It is based upon
  592. versions 1.00 of Chris Dunford's program.  The .zip file contains only the
  593. executable and documentation.  No source is included.
  594.  
  595. 23.3 X2B11.ZIP
  596.  
  597. X2B is written in 100% assembly language by Henry Nettles.  Again it is
  598. based upon Chris Dunford's program.  The zip file contains the executable
  599. and .asm source.  The documentation is in the source code.
  600.  
  601. 23.4 AVAILABILITY
  602.  
  603. All there .zip files are available at any SimTel Mirror site.  They are
  604. found in the SimTel/msdos/asmutil directory.
  605.  
  606. 23.5 THE REAL THING, EXE2BIN.EXE
  607.  
  608. If you need the real thing, EXE2BIN.EXE is available on the DOS
  609. Supplemental Diskettes.  This disks can be downloaded from microsoft.
  610.  
  611.     ftp://ftp.microsoft.com/peropsys/msdos/public/supplmnt
  612.  
  613.     DOS62SP.EXE     for MS DOS 6.2
  614.     DOS6SUPP.EXE    for MS DOS 6.0
  615.     SUP621.EXE      for MS DOS 6.21
  616.     SUP622.EXE      for MS DOS 6.22
  617.  
  618. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  619. Last changed: 8 Jan 96
  620.  
  621. ------------------------------
  622.  
  623. Subject: 24. ASM Tutorials Available
  624.  
  625. There are several assembly language tutorials available on the internet.
  626.  
  627. 24.1    FROM SIMTEL MIRRORS
  628.  
  629. From the SimTel Mirrors, e.g., oak.oakland.edu, there are two tutorials
  630. available in the simtel/msdos/asmutil directory.
  631.  
  632.     asmtutor.zip
  633.  
  634.     The tutorial is by Joshua Averbach.  It is old as it is dated in Jun
  635. 1988.  It is designed for the 8088 processor.
  636.  
  637.     primer2.zip
  638.  
  639.     This tutorial is designed specifically for the cheap assembler (CHASM)
  640. also available in this directory.
  641.  
  642. 24.2    GAVIN ESTEY'S TUTORIAL
  643.  
  644.     A new tutorial has been written by Gavin Estey.  He has provided his
  645. tutorial in ascii text and in Microsoft Word format.  They are available
  646. using anonymous ftp from:
  647.  
  648.     ftp://x2ftp.oulu.fi/pub/msdos/programming/docs
  649.     get asmtutx.zip                 For ascii text
  650.     get asmtutwp.zip                For MS Word document
  651.  
  652. 24.3 VLA's Assembly Language Tutorial
  653.  
  654. This tutorial is available directly or as part of the PC Games
  655. Encyclopedia.  This file is available from:
  656.     http://www.mds.mdh.se/~dat94avi/asmvla.zip
  657. or as part of the PC Games Encyclopedia:        
  658.     ftp://teeri.oulu.fi/pub/msdos/programming/gpe/pcgpe10.zip
  659.  
  660. 24.4 ASM Tutorial on University of Guadalajara Web Site
  661.  
  662. The on-line tutorial descibed below also is available as an ascii text.
  663.     http://udqftp.cencar.mx/ingles/tutor/assem.zip
  664.  
  665. 24.5    Web Sites
  666.  
  667. Assembly Language Tutorials
  668.     http://udgftp.cencar.udg.mx/ingles/tutor/Assembler.html
  669.         ASM Tutorial on University of Guadalajara Web Site
  670.     http://www.cit.ac.nz/smac/csware.htm
  671.         Version 2.6 of on-line 386 assembly languager course.  Self tests,
  672.         assignments, course notes, and software are included.
  673.     http://www.feldspar.com/~mbabcock/Programming/asmtut1.htm
  674.         Mike Babcock's ASM Tutorial
  675.     http://www.mds.mdh.se/~dat94avi/demoschool.htm
  676.         Tutorial emphasises video and gaming techniques and C and assembly
  677.         interface.
  678.  
  679. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  680. Last changed: 17 Feb 96
  681.  
  682.